TextPipe: Online Help
    Lesson 5 - Restrictions and sub filters
 

Submit feedback on this topic 

 Home  User Assistance   Tutorials   How to Use TextPipe
 Menus: File   Edit   Filters[ Convert   Add   Remove   Unicode   Replace   Special   Map   Email   Restrict ]  Tools   Window   Help   Advanced
Home
Up

 

 

In the last lesson we covered

  • Adding files.

In this lesson we'll look at

  • Restrictions and sub filters

What is a restriction?

Put simply, a restriction filter allows only a limited section of text to be processed. It does this using sub filters, which are shown below it and indented to the right in the filter view. A restriction filter to delete 11 lines starting at line 3 might look like this:

A restriction might be lines 100 to 199, columns 30 to 36, lines containing the text 'ERROR', a range of CSV or Tab-delimited fields or a combination of these subsets, such as columns 3 to 17 of lines 20 to 55. Restrictions and sub filters are very handy when you only want to apply a filter to a subset of the text, such as only performing a search and replace within the first 10 lines. Many other variations are possible. 

Click here to find out how to add a sub filter

Display of sub filters

TextPipe displays sub filters with a filter hierarchy or filter tree, very similar to the way that Windows Explorer shows drives A: and C: as subsets of My Computer. 

When you see a hierarchy of filters in TextPipe you know that a subset of the text is being treated specially. You can imagine the very top part of TextPipe's filter display to be selecting a very large subset - the entire file.

Creating a sub filter

To create a sub filter, you first need to Select the subset of text that you want to treat specially. You do this by choosing one of the filters in the Restrict Menu

Let's do this now. We will create a filter that will replace the word 'TextPipe' with 'TextPipe Pro' but only in lines 1 to 3:

  1. Open the filter called 'tutorial\lesson5.fll'
  2. From the Restrict Menu, choose Line Range
  3. Customize the Line Range filter so that it will 'Select lines 4..7'
  4. From the Replace Menu, add a Find exactly filter
  5. Customize the Find and Replace filter so that it will find the text 'TextPipe' and replace it with '*TextPipe Pro*'
  6. Drag and drop the Find and Replace filter so that it appears cascaded beneath the Line Range filter. To do this, you need to drag the Find and Replace filter to the right hand side of the tree view before you drop it (or ensure that you are holding down the Shift key). As you do this, the Status Bar will display the text 'Valid Action:Dropping Source filter as sub filter of Target filter'
  7. Click the 'Trial Run' button.

After the Trial run completes, you'll notice that only the second and third occurrences of 'TextPipe' have been replaced with 'TextPipe Pro'. This is exactly what we wanted - the Line Range sub filter has only passed lines 4 to 7 onto the Search and Replace sub filter. We can confirm this easily by adding an UPPERCASE filter after the Find and Replace filter.

  1. Select the Find and Replace filter
  2. From the Conversion Menu, add an UPPERCASE filter
  3. The UPPERCASE filter is added immediately after the Find and Replace filter
  4. Click the 'Trial Run' button.

With this example we can see that multiple filters can be applied within a sub filter.

Expanding and Collapsing the Filter Tree

Just as you would with Windows Explorer, you can single click the plus sign [+] next to a filter item to expand it out and show its sub filters, and you can single click the minus sign [-] next to a filter item to contract it and hide its sub filters. 

Comments

Comment filters can be used to document sub filters inside them. This is handy because you can hide the details of an operation inside a comment filter, and then collapse the comment filter so that the implementation is hidden.

Exercise 5

  1. Create a sub filter based on the example above that selects Columns 1 to 35 of lines 1 to 4, and replaces 'TextPipe' with 'TextPipe Pro' within that selection. Only one replacement should be performed.

Tutorial Index

 

 

 Contact Us   Support   Community   Tutorials and User Guides (online)
 © 1999-2005 Crystal Software. All rights reserved.